package com.ruoyi.web.controller.workSafetyStandardization.inspection;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.workSafetyStandardization.domain.InspectionMajorResult;
import com.ruoyi.workSafetyStandardization.service.IInspectionMajorResultService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 标准化考核专业评分Controller
 *
 * @author pengjie
 * @date 2023-12-18
 */
@RestController
@RequestMapping("/workSafetyStandardization/InspectionMajorresult")
public class InspectionMajorResultController extends BaseController
{
    @Autowired
    private IInspectionMajorResultService inspectionMajorResultService;

    /**
     * 查询标准化考核专业评分列表
     */
    @PreAuthorize("@ss.hasPermi('workSafetyStandardization:InspectionMajorresult:list')")
    @GetMapping("/list")
    public TableDataInfo list(InspectionMajorResult inspectionMajorResult)
    {
        startPage();
        List<InspectionMajorResult> list = inspectionMajorResultService.selectInspectionMajorResultList(inspectionMajorResult);
        return getDataTable(list);
    }

    /**
     * 导出标准化考核专业评分列表
     */
    @PreAuthorize("@ss.hasPermi('workSafetyStandardization:InspectionMajorresult:export')")
    @Log(title = "标准化考核专业评分", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InspectionMajorResult inspectionMajorResult)
    {
        List<InspectionMajorResult> list = inspectionMajorResultService.selectInspectionMajorResultList(inspectionMajorResult);
        ExcelUtil<InspectionMajorResult> util = new ExcelUtil<InspectionMajorResult>(InspectionMajorResult.class);
        util.exportExcel(response, list, "标准化考核专业评分数据");
    }

    /**
     * 获取标准化考核专业评分详细信息
     */
    @PreAuthorize("@ss.hasPermi('workSafetyStandardization:InspectionMajorresult:query')")
    @GetMapping(value = "/{majorResultId}")
    public AjaxResult getInfo(@PathVariable("majorResultId") String majorResultId)
    {
        return success(inspectionMajorResultService.selectInspectionMajorResultByMajorResultId(majorResultId));
    }

    /**
     * 新增标准化考核专业评分
     */
    @PreAuthorize("@ss.hasPermi('workSafetyStandardization:InspectionMajorresult:add')")
    @Log(title = "标准化考核专业评分", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InspectionMajorResult inspectionMajorResult)
    {
        return toAjax(inspectionMajorResultService.insertInspectionMajorResult(inspectionMajorResult));
    }

    /**
     * 修改标准化考核专业评分
     */
    @PreAuthorize("@ss.hasPermi('workSafetyStandardization:InspectionMajorresult:edit')")
    @Log(title = "标准化考核专业评分", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InspectionMajorResult inspectionMajorResult)
    {
        return toAjax(inspectionMajorResultService.updateInspectionMajorResult(inspectionMajorResult));
    }

    /**
     * 删除标准化考核专业评分
     */
    @PreAuthorize("@ss.hasPermi('workSafetyStandardization:InspectionMajorresult:remove')")
    @Log(title = "标准化考核专业评分", businessType = BusinessType.DELETE)
	@DeleteMapping("/{majorResultIds}")
    public AjaxResult remove(@PathVariable String[] majorResultIds)
    {
        return toAjax(inspectionMajorResultService.deleteInspectionMajorResultByMajorResultIds(majorResultIds));
    }
}
